import { BusinessType, ExportColType, TagType } from "./../../enums/sysEnum";
import { UploadUserFile } from "element-plus";

// 登录模块
export namespace Login {
  export interface ReqLoginForm {
    loginName: string;
    password: string;
  }
  export interface ResLogin {
    token: string;
    orgId?: string;
    loginName?: string;
    email?: string;
    sex?: number;
    userName?: string;
    userPicId?: string;
  }
  export interface ResAuthButtons {
    [key: string]: string[];
  }
}

export interface Params {
  _id: string;
  csName: string;
  csValue: string;
  type: string;
  csNote?: string;
  exValue?: string;
}

export interface ParamExts {
  _id: string;
  csName: string;
  name: string;
  value: string;
  tagType: string;
  pid?: string;
  sort: Number;
  exValue?: string;
}

export interface Org {
  _id: string;
  pid: string;
  name: string;
  leader: string;
  superVisor: string;
  assistantManage: [];
  type: string;
  sort: number;
  leaf: string;
  createDate: Date;
  createUser: string;
}

export interface Roles {
  _id: string;
  pid?: string;
  name: string;
  note?: string;
  key?: string;
  state?: string;
  sort?: number;
  createDate?: Date;
  createUser?: string;
}

export interface Users {
  _id: string;
  loginName: string;
  userName: string;
  nickName: string;
  userPicId: string;
  password: string;
  mobile: string;
  email: string;
  sex: string;
  post: string;
  workNo: string;
  orgId: string;
  sort: number;
  state: string;
  roleIds: string[];
}

export interface UserRoles {
  _id: string;
  loginName: string;
  userName: string;
  nickName: string;
  userPicId: string;
  password: string;
  mobile: string;
  email: string;
  sex: string;
  post: string;
  workNo: string;
  orgId: string;
  sort: number;
  state: string;
  roleIds: Roles[];
}

export interface EditUser {
  _id?: string;
  nickName?: string;
  workNo?: string;
}

export interface SelectUser {
  _id: string;
  userName: string;
}

export interface UserRole {
  _id?: string;
  userId: string;
  roleId: string;
}

export interface ManageUser {
  _id?: string;
  userId: string;
  userName: string;
  orgId: string;
  manage_user_rushjob: string;
  manage_user_performance_main: string;
  crossRate_main: string;
  manage_user_performance_sub: string;
  crossRate_sub: string;
}

export interface MenuButton {
  _id: string;
  menuId: string;
  menuName: string;
  name: string;
  key: string;
}

export interface RoleAuth {
  _id?: string;
  roleId?: string;
  authType: string;
  businessId: string;
  businessKey?: string;
  businessName: string;
  pBusinessId?: string;
}

export interface HtmlTemplate {
  _id?: string;
  key?: string;
  name?: string;
  content: string;
  note?: string;
}

export interface Item {
  _id?: string;
  item_no?: string; // 项目编码
  name?: string; // 项目名称
  year?: string; // 年度
  customer?: string; // 客户
  level?: string; // 项目等级
  state?: string; // 状态
  classify: string; // 类别
  release_org_id: string; // 项目交付负责组
  relase_charge_user?: string; // 项目交付负责人
  pre_sale_user: string; // 售前负责人
  dev_org_id?: string; // 研发产品组
  main_product: string; // 主产品
  support_product: string[]; // 辅助产品
  start_date: Date; // 立项日期
  completion_date: Date; // 完成日期
  plan_completion_date: Date; // 预计完成日期
  summary: string; // 备注
  files?: Array<UploadUserFile>;
  updated_at: Date; // 最后更新时间
  create_at?: Date;
  create_user: string;
}

// 产品
export interface Product {
  _id?: string;
  name?: string;
  summary: string;
  state?: string;
  business_domain: string;
  files?: Array<UploadUserFile>;
  charge_user?: string;
  create_at?: Date;
  create_user?: string;
}

export interface KeyTask {
  _id?: string;
  task_id?: string;
  p_task_id?: string;
  task_no: string;
  task_source: string;
  publish_user: string;
  work_plan: string;
  supervisor: string;
  manage_user: string;
  note: string;
  item_id?: string;
  name?: string;
  summary: string;
  user_id?: string;
  start_date?: string;
  end_date?: Date;
  category?: string;
  priority?: string;
  important?: string;
  state?: string;
  files?: Array<UploadUserFile>;
  create_at?: Date;
  create_user?: string;
  updated_at?: Date;
}

export interface UserAction {
  _id?: string;
  token?: string;
  businessType?: string;
  businessId?: string;
  type?: TagType;
  optType?: string;
  optUser?: string;
  optDate?: Date;
  optInfo?: string;
}

export interface Comment {
  _id?: string;
  businessType?: BusinessType;
  businessId?: string;
  optUser?: string;
  optDate?: Date;
  optInfo?: string;
}

interface HeaderCol {
  header: string;
  width: number;
  ext: {
    prop: string;
    mutil?: boolean;
    type: ExportColType;
    key?: string;
    value?: string;
    label?: string;
    func?: string;
  };
}

interface TableConfig {
  tableName: string;
  fields?: Array<string>;
  condition?: any;
}

export interface ExportObj {
  tableName: string;
  enumTypes: Array<string>;
  tableConfigs: Array<TableConfig>;
  header: Array<HeaderCol>;
  params: any;
  importStartIndex?: number;
  keyPropName?: string;
}

export interface Message {
  _id?: string;
  messageId: string;
  businessType: string;
  businessId: string;
  title: string;
  summary: string;
  type: string;
  linkUrl?: string;
  range?: string;
  pop?: string;
  toUsers?: string[];
  state?: string;
  create_at: Date;
  create_user?: string;
}

export namespace Testing {
  export interface TestingEnv {
    _id: string;
    name: string;
    summary: string;
    item_id: string;
    type: string; // 类别，测试，研发，演示，发布
    validity: string; // 有效期
    charge_user: string;
    accounts: Array<TestingAccount>[];
    urls: Array<TestingUrl>[];
    files?: Array<UploadUserFile>;
    create_at: Date;
    create_user: string;
  }

  export interface TestingAccount {
    name: string;
    password: string;
    type: string; // 管理员，普通用户
    note: string; // 备注
  }

  export interface TestingUrl {
    name: string;
    url: string;
    note: string;
  }
}

export namespace Code {
  // 代码仓库
  export interface Repository {
    _id: string;
    repository_id: string;
    name: string;
    title: string;
    summary: string;
    url: string;
    charge_user: string;
    org_id: string;
    create_at: Date;
    state: string;
    product_id: string;
    type: string;
    language: string;
    create_user: string;
    sonar: string;
    unit_test: string;
    service_type: string;
    service_name: string;
    service_version: string;
  }

  // 代码分支
  export interface Branch {
    rep_id: string;
    name: string;
    path: string;
    state: string;
    summary: string;
    create_at: Date;
    create_user: string;
  }
}

export interface Server {
  _id: string;
  level: string;
  use: string;
  type: string;
  ownerUser: string;
  useDate: string;
  system: string;
  resouceState: string;
  cpu: Number;
  ram: Number;
  hdd: Number;
  name: string;
  address: string;
  ip: string;
  account: string;
  pwd: string;
  firewall: string;
  soft: string;
  create_at: Date;
  create_user: string;
}

export interface RushJob {
  _id: string;
  userId: string;
  email: string;
  userName: string;
  workNo: string;
  workNote: string;
  orgId: string;
  startTime: Date;
  endTime: Date;
  itemId: string;
  isHoliday: string;
  workTime: Number;
  charge_user: string;
  approvalReason: string;
  state: string;
}

export interface Performance {
  _id?: string;
  chargeUser?: string;
  chargeUserName?: string;
  performanceDate: Date;
  performanceType: string;
  userId: string;
  userName: string;
  avgScore: Number;
  level: string;
  workload?: Number;
  workQuality?: Number;
  workEfficiency?: Number;
  workAttitude?: Number;
  workRule?: Number;
  teamShare?: Number;
  workload_detail?: string;
  workQuality_detail?: string;
  workEfficiency_detail?: string;
  workAttitude_detail?: string;
  workRule_detail?: string;
  teamShare_detail?: string;
  crossGroup: string;
  crossRate: string;
  orgId: string;
  summary?: string;
  state: string;
  chat_state: string;
  create_at: Date;
  create_user?: string;
}

export interface Backlog {
  _id: string;
  id: string;
  name: string;
  important: Number;
  estimate: Number;
  how: string;
  note: string;
  module: string;
  product: string;
  sprint: string;
  uiUser: string;
  testUser: string;
  tasks: [];
  startTestDate: Date;
  endTestDate: Date;
  startUiDate: Date;
  endUiDate: Date;
  startPoDate: Date;
  endPoDate: Date;
  createUser: string;
  createDate: Date;
}

export interface KeyEvent {
  _id: string;
  name: string;
  summary: string;
  type: string;
  occ_time: Date;
  itemId: string;
  customer: string;
  duty_orgId: string;
  duty_userId: string;
  files: [];
  state: string;
  createUser: string;
  createDate: Date;
}

export interface RestApi {
  _id?: string;
  serverName: string;
  packageName: string;
  className: string;
  fullCalssName: string;
  methodName: string;
  methodPath: string;
  classPath: string;
  fullPath: string;
  inParams: {};
  outParams: {};
  methodType: string;
  desc: string;
  product: string;
  function: string;
  state: string;
  create_at: Date;
  create_user?: string;
}

export interface PoModel {
  _id?: string;
  serverName: string;
  packageName: string;
  className: string;
  fullCalssName: string;
  tableName: string;
  modelDef: {};
  desc: string;
  state: string;
  product: string;
  function: string;
  create_at: Date;
  create_user?: string;
}

export interface SafeNote {
  _id?: string;
  type: string;
  name: string;
  content: string;
  size: Number;
  open: boolean;
  password: string;
  show_password: string;
  clickCount: Number;
  sharedUsers?: string[]; // 共享用户ID列表
  sharedUserNames?: string[]; // 共享用户名称列表
  last_use: Date;
  create_at: Date;
  create_user: string;
}

export interface Module {
  _id: string; // 模块ID
  pid: string; // 父模块ID
  name: string; // 模块名称
  note: string; // 模块描述
  productId: number; // 产品ID
  important: string; // 模块重要性
  manage: boolean; // 是否有后台管理功能
  app: boolean; // 是否有App端功能
  pc: boolean; // 是否有PC端功能
  web: boolean; // 是否有Web端功能
  pad: boolean; // 是否有Pad端功能
  po: string[]; // 产品负责人
  ui: string[]; // 模块UI负责人
  test: string[]; // 模块测试负责人
  om: string[]; // 模块O&M负责人
  dev: string[]; // 模块开发负责人
  state: string; // 模块状态
  sort: number;
  createUser: string;
  createDate: Date;
  orgId: number;
}

export interface Version {
  name: string;
  version: string;
  beginDate: Date;
  devEndDate: Date;
  endDate: Date;
  balanceDate: Date;
  orgId: string;
  create_at: Date;
  create_user: string;
}

// 工作日志
export interface WorkLog {
  _id?: string;
  /** 用户ID */
  userId?: string;
  /** 工作日期 */
  workDate: string;
  /** 工作总结 */
  summary: string;
  /** 工作思考 */
  think: string;
  /** 创建时间 */
  create_at: Date;
  /** 创建人 */
  create_user?: string;
}
